chore: add realtime tool output serialization edge cases#3077
Open
Aphroq wants to merge 2 commits intoopenai:mainfrom
Open
chore: add realtime tool output serialization edge cases#3077Aphroq wants to merge 2 commits intoopenai:mainfrom
Aphroq wants to merge 2 commits intoopenai:mainfrom
Conversation
seratch
requested changes
May 1, 2026
Member
seratch
left a comment
There was a problem hiding this comment.
Adding these patterns is great, but can you use parametrized testing?
@pytest.mark.parametrize(
("value", "expected"),
[
pytest.param(None, "null", id="none"),
pytest.param(["hello", 1, True, None], json.dumps(["hello", 1, True, None]), id="list"),
pytest.param(ToolResult(label="demo", values=[1, 2]), json.dumps({"label": "demo", "values": [1, 2]}), id="dataclass"),
pytest.param(b"abc", "b'abc'", id="bytes"),
],
)
def test_serialize_tool_output_edge_cases(self, value: Any, expected: str) -> None:
assert _serialize_tool_output(value) == expectedAdd focused realtime serialization coverage for _serialize_tool_output. - serialize None as JSON null - serialize lists as JSON arrays - serialize dataclass instances via asdict - fall back to string output for raw bytes
a14a863 to
057d013
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request adds focused edge-case coverage for realtime tool output serialization.
Test plan
uv run pytest tests/realtime/test_session.py -qIssue number
N/A
Checks
make lintandmake format